package com.lcm.learn.lcmcode.executorTest;

/**
 * @description:
 * @author: lcm
 * @create: 2019-11-28 11:23
 **/

public class VisibilityDemo {

    static int a=1;

    public static void main(String[] args) throws InterruptedException {
        Object o=new Object();
        o.hashCode();
        new ThreadA().start();
        Thread.sleep(1000);
        a++;
        System.out.println("main exit");
    }

    static class ThreadA extends Thread{
        @Override
        public void run() {
            while(a==2){

            }
            System.out.println("ThreadA exit");
        }
    }

//    private static boolean shutdown = false;
//
//    static class HelloThread extends Thread {
//        @Override
//        public void run() {
//            while(!shutdown){
//                // do nothing
//            }
//            System.out.println("exit hello");
//        }
//    }
//
//    public static void main(String[] args) throws InterruptedException {
//        new HelloThread().start();
//        Thread.sleep(1000);
//        shutdown = true;
//        System.out.println("exit main");
//    }

}
